import { http } from "@/utils/http";
import { Result, arrayResult } from "../types";

type data = {
  agvid?: number,
  agvname?: string,
  ip?: string,
  model?: string,
  status?: number,
  vehicletype?: number,
  note?: string
};

type search = {
  agvname?: string;
  ip?: string;
  cehicletype?: number;
  pageNumber: number,
  pageSize: number,
  sortName: string,
  sortType: number
}

type agvType = {
  state?: number,
  model?: number
}

// agv列表
export const agvList = (params?: search) => {
  return http.request<Result>("get", "/api/agv/List", { params });
};

// 车辆列表
export const GetAllAgv = (params?: agvType) => {
  return http.request<arrayResult>("get", "/api/agv/GetAllAgv", { params });
};

// 新增车辆
export const addAgv = (data: data) => {
  return http.request<Result>("post", "/api/agv/Add", { data });
};

// 修改车辆
export const updateAgv = (data: data) => {
  return http.request<Result>("post", "/api/agv/Update", { data });
};

// 删除车辆
export const delAgv = (data) => {
  return http.request<Result>("post", `/api/agv/Delete/${data.id}`, {params: data});
};

// 抢占控制权
export const ControlPower = (data) => {
  return http.request<Result>("post", `/api/job/ControlPower`, { params: data });
};

// 清除车辆错误
export const CleanError = (data) => {
  return http.request<Result>("post", `/api/job/CleanError`, { params: data });
};

// 修改状态
export const UpdateStatus = (data) => {
  return http.request<Result>("post", `/api/agv/UpdateStatus?id=${data.id}`, { data: data.state });
};

// 确认定位
export const Comfirmloc = (data) => {
  return http.request<Result>("post", `/api/job/Comfirmloc`, { params: data });
};

// 手动定位
export const Reloc = (data) => {
  return http.request<Result>("post", `/api/job/Reloc`, { params: data });
};

// 车辆型号
export const agvModels = () => {
  return http.request<arrayResult>("get", `/api/Dict/ListByParentCode/agvModel`, {});
};

// 车型
export const vehicletypes = () => {
  return http.request<arrayResult>("get", `/api/Dict/ListByParentCode/vehicletypes`, {});
};

// 品牌 
export const agvBrand = () => {
  return http.request<arrayResult>("get", `/api/Dict/ListByParentCode/agvBrand`, {});
};

// 详情
export const getAgv = (id:number) => {
  return http.request<arrayResult>("get", `/api/agv/Get/${id}`, {});
};
